package com.online.service;

import com.online.dao.StudentAnswerMapper;
import com.online.entity.StudentAnswer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentAnswerServiceImpl implements StudentAnswerService {

    @Autowired
    StudentAnswerMapper studentAnswerMapper;

    @Override
    public int insertAStudentAnswer(StudentAnswer studentAnswer) {
        return studentAnswerMapper.insertARecord(studentAnswer);
    }

    @Override
    public List<StudentAnswer> showAStudentAnswer(String studentNumber, Integer examId) {
        return studentAnswerMapper.selectAStudentAnswer(studentNumber,examId);
    }

    @Override
    public List<Integer> showStudentAnswerExamId(String studentNumber) {
        return studentAnswerMapper.selectExamIdByStudentNumber(studentNumber);
    }

    @Override
    public List<StudentAnswer> showStudentOptionAnswer(String studentNumber, Integer examId) {
        return studentAnswerMapper.selectOptionAnswer(studentNumber,examId);
    }

    @Override
    public List<StudentAnswer> showStudentBlankAnswer(String studentNumber, Integer examId) {
        return studentAnswerMapper.selectBlanksAnswer(studentNumber,examId);
    }

    @Override
    public int deleteARecord(int examId) {
        return studentAnswerMapper.deleteARecord(examId);
    }

    @Override
    public  List<StudentAnswer>  countDeliver(Integer examId) {
        return studentAnswerMapper.showStudentNumberByExamId(examId);
    }

    @Override
    public List<StudentAnswer> showStudentAnswerList(String studentNumber) {
        return studentAnswerMapper.showStudentAnswerList(studentNumber);
    }

    @Override
    public int deleteRecordByStudentNumber(String studentNumber) {
        return studentAnswerMapper.deleteByStudentNumber(studentNumber);
    }
}
